#ifndef SUBMISSION_H
#define SUBMISSION_H
#include <cstring>
#include <cstdio>
#include "../utils/message.h"

class SubmissionMessage : public IMessage {
public:
	//const static int MSG_TYPE = 200;
	const static int MSG_LENGTH = 100;

	SubmissionMessage(int pType) {
		mMsgBuf = new tMsgBuf;
		//mType = MSG_TYPE;
		mType = pType;
		mMsgBuf->type = mType;
		
		memset(mMsgBuf->submissionId , 0 , MSG_LENGTH);
	}
	
	~SubmissionMessage() {
		delete mMsgBuf;
	}

	virtual int getLength() {
		//return sizeof(this->mMsgBuf);
		return MSG_LENGTH;
	}
	
	virtual void* getBuffer() {
		return this->mMsgBuf;
	}
	
	virtual void setBuffer(void* pBuffer , int pSize) {
		delete mMsgBuf;
		mMsgBuf = new tMsgBuf;
		memcpy(mMsgBuf , pBuffer , pSize);
	}
	
	long getMessageType() {
		return mType;
	}
	
	/*void setProblemId(unsigned long pProblemId) {
		this->mMsgBuf->problemId = pProblemId;
	}*/
	
	void setSubmissionId(const char pSubmissionId[100]) {
		memset(mMsgBuf->submissionId , 0 , MSG_LENGTH);
		sprintf(mMsgBuf->submissionId , "%s" , pSubmissionId);
	}
	
	/*unsigned long getProblemId() {
		return mMsgBuf->problemId;
	}*/
	
	string getSubmissionId() {
		return mMsgBuf->submissionId;
	}

private:
	long mType;

	typedef struct msg_buf {
		long type;
		//unsigned long problemId;
		char submissionId[MSG_LENGTH];
	} tMsgBuf;
	
	tMsgBuf* mMsgBuf;
};

#endif
